<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String basePath=request.getScheme()+"://"+ request.getServerName()+":"+request.getServerPort()+ request.getContextPath()+"/";
%>
<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath%>static/">
	<meta charset="UTF-8">
	<link href="/crm/static/jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
	<script type="text/javascript" src="/crm/static/jquery/jquery-1.11.1-min.js"></script>
	<script type="text/javascript" src="/crm/static/jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="/crm/static/js/jquery-3.5.1.js"></script>
</head>
<body>
<script type="text/javascript">
	window.onload=function () {
		if(window.top!=window){
			window.top.location=window.location;
		}
		var obj=$(":text");
		//在页面加载完毕后自动让用户名输入框获得焦点并且清空所有文本框
		$("[name]").val("");
		obj.focus();
	}
	window.onkeydown=function (event) {
		if(event.keyCode==13){
			login();
		}
	}
	function login() {
		var msg=$("#msg");
		var loginActObj=$("[name='loginAct']");
		var pswObj=$("[name='loginPwd']");
		var loginAct=$.trim(loginActObj.val());
		var psw=$.trim(pswObj.val());
		if(!(loginAct!=""&&loginAct.length!=0)){
			msg.text("用户名不能为空");
			loginActObJ.focus();
			return;
		}
		if(!(psw!=""&&psw.length>0)){
			msg.text("密码不能为空");
			pswObj.focus();
			return;
		}
		$.ajax({url:"<%=request.getContextPath()%>/userLoginCheck",
			data:{"loginAct":loginAct,"loginPwd":psw},
			dataType:"json",success:function (data) {
				if(data.status){
					window.location.href="workbench/index.jsp";
				}else {
					msg.text(data.errorMessage);
				}
			},type:"Post"});
	}
</script>
<div style="position: absolute; top: 0px; left: 0px; width: 60%;">
	<img src="image/IMG_7114.JPG" style="width: 100%; height: 90%; position: relative; top: 50px;">
</div>
<div id="top" style="height: 50px; background-color: #3C3C3C; width: 100%;">
	<div style="position: absolute; top: 5px; left: 0px; font-size: 30px; font-weight: 400; color: white; font-family: 'times new roman'">CRM &nbsp;<span style="font-size: 12px;">&copy;2017&nbsp;动力节点</span></div>
</div>

<div style="position: absolute; top: 120px; right: 100px;width:450px;height:400px;border:1px solid #D5D5D5">
	<div style="position: absolute; top: 0px; right: 60px;">
		<div class="page-header">
			<h1>登录</h1>
		</div>
		<form id="loginForm" action="workbench/index.jsp" class="form-horizontal" role="form">
			<div class="form-group form-group-lg">
				<div style="width: 350px;">
					<input class="form-control" type="text" placeholder="用户名" name="loginAct">
				</div>
				<div style="width: 350px; position: relative;top: 20px;">
					<input class="form-control" type="password" placeholder="密码" name="loginPwd">
				</div>
				<div class="checkbox"  style="position: relative;top: 30px; left: 10px;">

					<span id="msg" style="color: red"></span>

				</div>
				<button onclick="login()" id="submit" type="button" class="btn btn-primary btn-lg btn-block"  style="width: 350px; position: relative;top: 45px;">登录</button>
			</div>
		</form>
	</div>
</div>
</body>
</html>
